<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:ace="http://www.icefaces.org/icefaces/components"
   xmlns:icecore="http://www.icefaces.org/icefaces/core">
   <h:body> 
      <ui:composition template="/WEB-INF/templates/adminuser/template.xhtml">
         <ui:define name="content">
         
		<f:event type="preRenderView" listener="#{deviceTypeInfoBean.forwardTypesIfNotSelection}"/>
         
              <h:form id="form-devicetype">
              
              		<icecore:singleSubmit />
              
		            <ace:panel     closable  = "false"
			                       toggleable= "false"
			                       collapsed = "false" >
			       		<h:panelGrid  columns="2"  style="margin-left:auto; margin-right:auto;">
				            <h:outputText   value="#{msgs['devicetypedata.name']}"/>
				            <h:inputText    value="#{deviceTypeInfoBean.selected.name}" /> 
				        </h:panelGrid>
				        <h:commandButton  id="saveBttn" value="#{msgs['devicetypedata.saveChanges']}" 
	                                         actionListener="#{deviceTypeInfoBean.selected.saveChanges}"
	                                         action="devicetypes"/>
		            </ace:panel>
		            
		            
		            <ace:panel id="field-list" header="#{msgs['devicetypedata.fieldlist']}"
                               toggleable="true" toggleSpeed="1000">
			            <ace:dataTable id="dev-field-list"
		                     value="#{deviceTypeInfoBean.selected.fields}"
		                     var="field">
	                      		<ace:column id="field-list-name-col" headerText="#{msgs['devicetypedata.field.name']}">
	                          		<h:inputText id="name-row" value="#{field.name}"/>
	                      		</ace:column>  
		                      	<ace:column id="field-list-address-col" headerText="#{msgs['devicetypedata.field.address']}">
		                           	<h:panelGrid  columns="1"  style="margin-left:auto; margin-right:auto;">
		                           	<h:inputText id="address-row" label="#{msgs['devicetypedata.addresslabel']}" 
		                           	             value="#{field.address}">
	                                  <f:validateLongRange minimum="0" maximum="65535" />
	                        		</h:inputText>
	                        		<h:message for="address-row" />
	                        		</h:panelGrid> 
		                      	</ace:column>
		                      	<ace:column id="field-list-registertype-col" headerText="#{msgs['devicetypedata.field.modbustype']}">
			                      	<h:selectOneMenu value="#{field.type}">
							   			<f:selectItem itemValue="#{modbusmethod.holding}" itemLabel="#{msgs['devicetypedata.field.modbustype.holding']}" />
							   			<f:selectItem itemValue="#{modbusmethod.input}" itemLabel="#{msgs['devicetypedata.field.modbustype.input']}" />
							   			<f:selectItem itemValue="#{modbusmethod.coil}" itemLabel="#{msgs['devicetypedata.field.modbustype.coil']}" />
							   			<f:selectItem itemValue="#{modbusmethod.discrete}" itemLabel="#{msgs['devicetypedata.field.modbustype.discrete']}" />
	   								</h:selectOneMenu>
		                      	</ace:column>
		                      	<ace:column id="field-list-bitnummber-col" headerText="#{msgs['devicetypedata.field.bitnummber']}">
                      		   		<h:panelGrid  columns="1"  style="margin-left:auto; margin-right:auto;">
                      		   		<h:selectBooleanCheckbox id="check-row" value="#{field.bittype}" disabled="#{field.disableBitCheck}"/>
		                           	<h:inputText id="bitoffset-row"  label="#{msgs['devicetypedata.bitoffset']}"
			                           	             value="#{field.bitnummber}" disabled="#{field.disableBitOffset}">
	                                  <f:validateLongRange minimum="0" maximum="15" />
	                        		</h:inputText>
	                        		<h:message for="bitoffset-row" />
	                        		</h:panelGrid> 
		                      	</ace:column>
		                      	<ace:column id="field-list-commands-col" >
		                      		<h:commandButton  id="newBttn" value="#{msgs['devicetypedata.field.delete']}" 
	                                         actionListener="#{deviceTypeInfoBean.selected.delete(field)}"/>
		                      	</ace:column>
	               		</ace:dataTable>  
	               		<h:commandButton  id="newFieldBttn" value="#{msgs['devicetypedata.newField']}" 
	                                         actionListener="#{deviceTypeInfoBean.selected.newField}"/>
               		</ace:panel>
               		
               		
		            <ace:panel id="command-list" header="#{msgs['devicetypedata.commandlist']}"
                               toggleable="true" toggleSpeed="1000">
	                    <ace:panel id="simplecommand-list" header="#{msgs['devicetypedata.simplecommandlist']}"
	                            toggleable="true" toggleSpeed="1000">
				            <ace:dataTable id="dev-simplecommand-list"
			                     value="#{deviceTypeInfoBean.selected.simpleCommands}"
			                     var="cmd">
		                      		<ace:column id="cmd-list-name-col" headerText="#{msgs['devicetypedata.cmd.name']}">
		                          		<h:inputText id="cmd-list-name-row" value="#{cmd.name}"/>
		                      		</ace:column>  
			                      	<ace:column id="cmd-list-address-col" headerText="#{msgs['devicetypedata.cmd.address']}">
			                           	<h:panelGrid  columns="1"  style="margin-left:auto; margin-right:auto;">
			                           	<h:inputText id="cmd-list-address-row" label="#{msgs['devicetypedata.addresslabel']}" value="#{cmd.address}">
	                                  <f:validateLongRange minimum="0" maximum="65535" />
	                        		</h:inputText>
	                        		<h:message for="cmd-list-address-row" /> 
	                        		</h:panelGrid>
			                      	</ace:column>
			                      	<ace:column id="cmd-list-registertype-col" headerText="#{msgs['devicetypedata.cmd.modbustype']}">
				                      	<h:selectOneMenu value="#{cmd.method}">
								   			<f:selectItem itemValue="#{modbusmethod.holding}" itemLabel="#{msgs['devicetypedata.cmd.modbustype.holding']}" />
								   			<f:selectItem itemValue="#{modbusmethod.coil}" itemLabel="#{msgs['devicetypedata.cmd.modbustype.coil']}" />
		   								</h:selectOneMenu>
			                      	</ace:column>
			                      	<ace:column id="cmd-list-bitnummber-col" headerText="#{msgs['devicetypedata.cmd.bitnumber']}">
			                           	<h:panelGrid  columns="1"  style="margin-left:auto; margin-right:auto;">
			                           	<h:inputText id="cmd-list-bitnummberrow" label="#{msgs['devicetypedata.bitoffset']}"
			                           	             value="#{cmd.bitnummber}" disabled="#{cmd.disableBitOffset}">
	                                        <f:validateLongRange minimum="0" maximum="15" />
	                        		    </h:inputText>
	                        		    <h:message for="cmd-list-bitnummberrow" /> 
	                        		    </h:panelGrid>
			                      	</ace:column>
			                      	<ace:column id="cmd-list-commands-col" >
			                      		<h:commandButton  id="delBttn" value="#{msgs['devicetypedata.cmd.delete']}" 
		                                         actionListener="#{deviceTypeInfoBean.selected.delete(cmd)}"/>
			                      	</ace:column>
		               		</ace:dataTable>  
		               		<h:commandButton  id="newSimpleCmdBttn" value="#{msgs['devicetypedata.newSimpleCommand']}" 
		                                         actionListener="#{deviceTypeInfoBean.selected.newSimpleCommand}"/>
	               		</ace:panel>
	               		
	                    <ace:panel id="compoundcommand-list" header="#{msgs['devicetypedata.compoundcommandlist']}"
	                            toggleable="true" toggleSpeed="1000">
				            <ace:dataTable id="dev-compoundcommand-list"
			                     value="#{deviceTypeInfoBean.selected.compoundCommands}"
			                     var="cmd">
		                      		<ace:column id="cmd-list-name-col" headerText="#{msgs['devicetypedata.cmd.name']}">
		                          		<h:inputText id="cmd-list-name-row" value="#{cmd.name}"/>
		                      		</ace:column>  
			                      	<ace:column id="cmd-list-address-col" headerText="#{msgs['devicetypedata.cmd.address']}">
			                           	<h:panelGrid  columns="1"  style="margin-left:auto; margin-right:auto;">
			                           	<h:inputText id="cmd-list-address-row" label="#{msgs['devicetypedata.addresslabel']}" value="#{cmd.address}">
	                                       <f:validateLongRange minimum="0" maximum="65535" />
	                        		    </h:inputText>
	                        		    <h:message for="cmd-list-address-row" /> 
	                        		    </h:panelGrid>
			                      	</ace:column>
			                      	<ace:column id="cmd-list-commands-col" >
			                      		<h:commandButton  id="delBttn" value="#{msgs['devicetypedata.cmd.delete']}" 
		                                         actionListener="#{deviceTypeInfoBean.selected.delete(cmd)}"/>
			                      	</ace:column>
		               		</ace:dataTable>  
		               		<h:commandButton  id="newCompoundCmdBttn" value="#{msgs['devicetypedata.newCompoundCommand']}" 
		                                         actionListener="#{deviceTypeInfoBean.selected.newCompoundCommand}"/>
	               		</ace:panel>
               		</ace:panel>
               		
               		<ace:panel id="alarm-list" header="#{msgs['devicetypedata.alarmlist']}"
                               toggleable="true" toggleSpeed="1000">
			            <ace:dataTable id="dev-alarm-list"
		                     value="#{deviceTypeInfoBean.selected.alarms}"
		                     var="alr">
	                      		<ace:column id="alr-list-name-col" headerText="#{msgs['devicetypedata.alr.name']}">
	                          		<h:inputText id="alr-list-name-row" value="#{alr.name}"/>
	                      		</ace:column>  
		                      	<ace:column id="cmd-list-address-col" headerText="#{msgs['devicetypedata.alr.field']}">
		                           	<h:selectOneMenu value="#{alr.field}">
							   			<f:selectItems value="#{deviceTypeInfoBean.selected.fields}" var="field"
							   			itemLabel="#{field.name}" itemValue="#{field.hash}" />
						   			</h:selectOneMenu>
		                      	</ace:column>
		                      	<ace:column id="alr-list-registertype-col" headerText="#{msgs['devicetypedata.alr.method']}">
			                      	<h:selectOneMenu value="#{alr.method}">
							   			<f:selectItem itemValue="#{alarmsmethod.equal}"      itemLabel="#{msgs['devicetypedata.alarm.method.equal']}" />
							   			<f:selectItem itemValue="#{alarmsmethod.less}"       itemLabel="#{msgs['devicetypedata.alarm.method.less']}" />
							   			<f:selectItem itemValue="#{alarmsmethod.mayor}"      itemLabel="#{msgs['devicetypedata.alarm.method.mayor']}" />
							   			<f:selectItem itemValue="#{alarmsmethod.notEqual}"   itemLabel="#{msgs['devicetypedata.alarm.method.notequal']}" />
							   			<f:selectItem itemValue="#{alarmsmethod.lessEqual}"  itemLabel="#{msgs['devicetypedata.alarm.method.lessequal']}" />
							   			<f:selectItem itemValue="#{alarmsmethod.mayorEqual}" itemLabel="#{msgs['devicetypedata.alarm.method.mayorequal']}" />
	   								</h:selectOneMenu>
		                      	</ace:column>
		                      	<ace:column id="alr-list-value-col" headerText="#{msgs['devicetypedata.alr.value']}">
		                      	<h:panelGrid  columns="1"  style="margin-left:auto; margin-right:auto;">
		                           	<h:inputText id="value-row" label="#{msgs['devicetypedata.valuelabel']}" value="#{alr.value}">
	                                    <f:validateLongRange minimum="0" maximum="65535" />
	                        		</h:inputText>
	                        		<h:message for="value-row" /> 
	                        		</h:panelGrid>
		                      	</ace:column>
			                      <ace:column id="alr-list-commands-col" >
			                      		<h:commandButton  id="delBttn" value="#{msgs['devicetypedata.alr.delete']}" 
		                                         actionListener="#{deviceTypeInfoBean.selected.delete(alr)}"/>
			                     </ace:column>
	               		</ace:dataTable>  
	               		<h:commandButton  id="newAlarmBttn" value="#{msgs['devicetypedata.newAlarm']}" disabled = "#{deviceTypeInfoBean.selected.alarmdisabled}"
	                                         actionListener="#{deviceTypeInfoBean.selected.newAlarm}"/>
               		</ace:panel>
	           </h:form>
	       </ui:define>		
      </ui:composition> 
   </h:body> 
</html>	